import request from '@/config/axios'

export interface PageParam {
  pageNo: number
  pageSize: number
}

export interface EvalSubjectVO {
  id?: number
  planId: number
  subjectName: string
  subjectCode: string
  subjectType: string
  subjectWeight: number
  passingScore: number
  maxScore: number
  examDuration?: number
  examLocation?: string
  examStartTime?: Date
  examEndTime?: Date
  subjectDescription?: string
  creator?: string
  createTime?: Date
  updater?: string
  updateTime?: Date
  deleted?: boolean
  tenantId?: number
}

export interface EvalSubjectPageReqVO extends PageParam {
  planId?: number
  subjectName?: string
  subjectCode?: string
  subjectType?: string
  createTime?: Date[]
}

export interface EvalSubjectBatchCreateReqVO {
  planId: number
  subjectList: EvalSubjectVO[]
}

export interface EvalSubjectCopyReqVO {
  sourceSubjectIds: number[]
  targetPlanId: number
}

export interface EvalSubjectCreateByTemplateReqVO {
  planId: number
  templateId: number
}

// 查询评价科目分页
export const getSubjectPage = (params: EvalSubjectPageReqVO) => {
  return request.get({ url: '/eval/subject/page', params })
}

// 查询评价科目详情
export const getSubject = (id: number) => {
  return request.get({ url: '/eval/subject/get?id=' + id })
}

// 新增评价科目
export const createSubject = (data: EvalSubjectVO) => {
  return request.post({ url: '/eval/subject/create', data })
}

// 修改评价科目
export const updateSubject = (data: EvalSubjectVO) => {
  return request.put({ url: '/eval/subject/update', data })
}

// 删除评价科目
export const deleteSubject = (id: number) => {
  return request.delete({ url: '/eval/subject/delete?id=' + id })
}

// 导出评价科目
export const exportSubject = (params: EvalSubjectPageReqVO) => {
  return request.download({ url: '/eval/subject/export-excel', params })
}

// 根据计划ID获得科目列表
export const getSubjectListByPlanId = (planId: number) => {
  return request.get({ url: '/eval/subject/list-by-plan?planId=' + planId })
}

// 根据科目类型获得科目列表
export const getSubjectListBySubjectType = (subjectType: string) => {
  return request.get({ url: '/eval/subject/list-by-type?subjectType=' + subjectType })
}

// 批量创建评价科目
export const batchCreateSubjects = (data: EvalSubjectBatchCreateReqVO) => {
  return request.post({ url: '/eval/subject/batch-create', data })
}

// 复制科目到其他计划
export const copySubjectsToOtherPlan = (data: EvalSubjectCopyReqVO) => {
  return request.post({ url: '/eval/subject/copy-to-plan', data })
}

// 根据模板创建科目
export const createSubjectsByTemplate = (data: EvalSubjectCreateByTemplateReqVO) => {
  return request.post({ url: '/eval/subject/create-by-template', data })
}
